home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 2: Applications / Linux Cubed Series 2 - Applications.iso / editors / emacs / xemacs / xemacs-1.006 / xemacs-1 / lib / xemacs-19.13 / lisp / pcl-cvs / pcl-cvs-lucid.el < prev    next >
Encoding:
Text File  |  1995-03-25  |  4.6 KB  |  136 lines

  1. ;;; Mouse and font support for PCL-CVS 1.3 running in Lucid GNU Emacs
  2. ;; @(#) Id: pcl-cvs-lucid.el,v 1.2 1993/05/31 19:37:34 ceder Exp 
  3. ;; Copyright (C) 1992-1993 Free Software Foundation, Inc.
  4.  
  5. ;; This file is part of XEmacs.
  6.  
  7. ;; XEmacs is free software; you can redistribute it and/or modify it
  8. ;; under the terms of the GNU General Public License as published by
  9. ;; the Free Software Foundation; either version 2, or (at your option)
  10. ;; any later version.
  11.  
  12. ;; XEmacs is distributed in the hope that it will be useful, but
  13. ;; WITHOUT ANY WARRANTY; without even the implied warranty of
  14. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  15. ;; General Public License for more details.
  16.  
  17. ;; You should have received a copy of the GNU General Public License
  18. ;; along with XEmacs; see the file COPYING.  If not, write to the Free
  19. ;; Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  20.  
  21.  
  22. ;; This simply adds a menu of the common CVS commands to the menubar and to
  23. ;; the right mouse button.  Clicking right moves point, and then pops up a
  24. ;; menu from which commands can be executed.
  25. ;; 
  26. ;; This could stand to be a lot more clever: for example, the "Commit Changes"
  27. ;; command should only be active on files for which there is something to
  28. ;; commit.  Also, some indication of which files the command applies to
  29. ;; (especially in the presence of multiple marked files) would be nice.
  30. ;;
  31. ;; Middle-click runs find-file.
  32.  
  33.  
  34. (require 'pcl-cvs)
  35.  
  36. (defvar cvs-menu
  37.   '("CVS Commands"
  38.     ["Find File"            cvs-mode-find-file        t]
  39.     ["Find File Other Window"        cvs-mode-find-file-other-window    t]
  40.     ["Interactively Merge (emerge)"    cvs-mode-emerge            t]
  41.     ["Diff against Repository"        cvs-mode-diff-cvs        t]
  42.     ["Diff against Backup Version"    cvs-mode-diff-backup        t]
  43.     "----"
  44.     ["Commit Changes to Repository"    cvs-mode-commit            t]
  45.     ["Revert File from Repository"    cvs-mode-undo-local-changes    t]
  46.     ["Add File to Repository"        cvs-mode-add            t]
  47.     ["Remove File from Repository"    cvs-mode-remove-file        t]
  48.     ["Ignore File"            cvs-mode-ignore            t]
  49.     ["Hide File"            cvs-mode-acknowledge        t]
  50.     ["Hide Handled Files"        cvs-mode-remove-handled        t]
  51.     "----"
  52.     ["Add ChangeLog Entry"    cvs-mode-add-change-log-entry-other-window t]
  53.     ["Show CVS Log"            cvs-mode-log            t]
  54.     ["Show CVS Status"            cvs-mode-status            t]
  55.     "----"
  56.     ["Mark File"            cvs-mode-mark            t]
  57.     ["Unmark File"            cvs-mode-unmark            t]
  58.     ["Mark All Files"            cvs-mode-mark-all-files        t]
  59.     ["Unmark All Files"            cvs-mode-unmark-all-files    t]
  60.     "----"
  61.     ["Quit"                bury-buffer            t]
  62.     ))
  63.  
  64. (defun cvs-menu (e)
  65.   (interactive "e")
  66.   (mouse-set-point e)
  67.   (beginning-of-line)
  68.   (if cvs-update-running (error "CVS update is running"))
  69.   (or (looking-at "^[* ] ") (error "No CVS file line here"))
  70.   (popup-menu cvs-menu))
  71.  
  72. (defun cvs-mouse-find-file (e)
  73.   (interactive "e")
  74.   (mouse-set-point e)
  75.   (beginning-of-line)
  76.   (if cvs-update-running (error "CVS update is running"))
  77.   (or (looking-at "^[* ] ") (error "No CVS file line here"))
  78.   (cvs-mode-find-file (point)))
  79.  
  80. (define-key cvs-mode-map 'button3 'cvs-menu)
  81. (define-key cvs-mode-map 'button2 'cvs-mouse-find-file)
  82.  
  83. (make-face 'cvs-header-face)
  84. (make-face 'cvs-filename-face)
  85. (make-face 'cvs-status-face)
  86.  
  87. (or (face-differs-from-default-p 'cvs-header-face)
  88.     (copy-face 'italic 'cvs-header-face))
  89.  
  90. (or (face-differs-from-default-p 'cvs-filename-face)
  91.     (copy-face 'bold 'cvs-filename-face))
  92.  
  93. (or (face-differs-from-default-p 'cvs-status-face)
  94.     (copy-face 'bold-italic 'cvs-status-face))
  95.  
  96.  
  97. (defun pcl-mode-motion-highlight-line (event)
  98.   (if (save-excursion
  99.     (let* ((window (event-window event))
  100.            (buffer (and window (event-buffer event)))
  101.            (point (and buffer (event-point event))))
  102.       (and point
  103.            (progn
  104.          (set-buffer buffer)
  105.          (goto-char point)
  106.          (beginning-of-line)
  107.          (looking-at "^[* ] ")))))
  108.       (mode-motion-highlight-line event)))
  109.  
  110. (defconst pcl-cvs-font-lock-keywords
  111.   '(("^In directory \\(.+\\)$" 1 cvs-header-face)
  112.     ("^[* ] \\w+ +\\(ci\\)" 1 cvs-status-face)
  113.     ("^[* ] \\(Conflict\\|Merged\\)" 1 cvs-status-face)
  114.     ("^[* ] \\w+ +\\(ci +\\)?\\(.+\\)$" 2 cvs-filename-face)
  115.     )
  116.   "Patterns to highlight in the *cvs* buffer.")
  117.  
  118. (defun pcl-cvs-fontify ()
  119.   ;;
  120.   ;; set up line highlighting
  121.   (require 'mode-motion)
  122.   (setq mode-motion-hook 'pcl-mode-motion-highlight-line)
  123.   ;;
  124.   ;; set up menubar
  125.   (if (and current-menubar (not (assoc "CVS" current-menubar)))
  126.       (progn
  127.     (set-buffer-menubar (copy-sequence current-menubar))
  128.     (add-menu nil "CVS" (cdr cvs-menu))))
  129.   ;;
  130.   ;; fontify mousable lines
  131.   (set (make-local-variable 'font-lock-keywords) pcl-cvs-font-lock-keywords)
  132.   (font-lock-mode 1)
  133.   )
  134.  
  135. (add-hook 'cvs-mode-hook 'pcl-cvs-fontify)
  136.